import {request, upload, arrayBuffer} from './request'

const api = {}

//  文件上传接口
api.uploadFile = (filePath, params) => {
  return upload({
    filePath: filePath,
    params: params
  })
}

// 地址信息
api.areaInfo = (params) => {
  return request({
    url: '',
    params: params,
  })
}

//  获取首页信息
api.getHomePage = (params) => {
  return request({
    // url: '/yswemini/homePageForWeMini/getHomePage',
    url: '/yswemini/homePageNew/getHomePage',
    params: params
  })
}

//  首页用户信息汇总
api.userInfoIndex = (cancelObj) => {
  return request({
    url: '/yswemini/myInfo/index',
    cancelObj: cancelObj
  })
}

//  获取用户信息
api.getUserInfo = (params) => {
  return request({
    url: '/ysucenter/weMini/getUserInfoByCode',
    params: params,
  })
}

//  我的页面信息
api.getUserMy = (params) => {
  return request({
    url: '/ysapi/myInfo/index',
    params: params,
  })
}
// token
api.getToken = (params) => {
  return request({
    url: '/ysapi/token/getToken',
    params: params,
  })
}
// 加入购物车
api.addCart = (params) => {
  return request({
    url: '/ysapi/cart/sku/add',
    params: params,
    type:'post',
  })
}
// 换绑卡列表
api.checkVipCardList= (params) => {
  return request({
    url: '/ysapi/myInfo/cards/checkVipCardList',
    params:params,
    type:'get',
  })
}
//  获取用户信息
api.getUserInfoDetail = () => {
  return request({
    url: '/yswemini/myInfo/detail',
  })
}

//  换取用户手机号
api.getUserPhone = (params) => {
  return request({
    url: '/ysucenter/weMini/getUserPhone',
    params: params
  })
}

//  判断小程序分享人是否为员工
api.bindEmployee = (params) => {
  return request({
    url: '/yswemini/share/bindEmployee',
    params: params,
    type: 'post'
  })
}

//  企业微信换取手机号
api.getUserInfoByCode = (params) => {
  return request({
    url: '/yswemini/wxWork/getUserInfoByCode',
    params: params
  })
}

//  绑定手机号
api.register = (params) => {
  return request({
    url: '/ysucenter/weMini/regist',
    params: params,
    type: 'post'
  })
}
// 退出登录
api.logout = (params) => {
  return request({
    url: '/ysapi/myInfo/logout',
    params: params,
  })
}
//  获取用户二维码
api.getUserCode = (params) => {
  return arrayBuffer({
    url: '/yswemini/homePageForWeMini/twoDimensionCode',
    params: params
  })
}
//  获取用户条形码
api.getUserBarCode = (params) => {
  return arrayBuffer({
    url: '/yswemini/homePageForWeMini/barcode',
    params: params
  })
}

//  获取wxID
api.getWxIdByLocation = (params) => {
  return request({
    url: '/yswemini/homePageForWeMini/getWxIdByLocation',
    params: params
  })
}


//  获取老卡列表
api.getOldCardList = (params) => {
  return request({
    url: '/ysapi/myInfo/cards/checkVipCard',
    params: params
  })
}

// 门店和店铺的开卡
api.newCard = (params) => {
  return request({
    url: '/ysapi/store/chainCreateCard',
    params: params,
    type:'post',
  })
}

// 门店和店铺的绑卡
api.bindCard = (params) => {
  return request({
    url: '/ysapi/store/chainBindCard',
    params: params,
    type:'post',
  })
}

//  根据邀请码获取门店信息
api.getChainInfoByCode = (params) => {
  return request({
    url: '/yswemini/chain/getChainAndCardInfoByCode',
    params: params
  })
}


//  换取分佣链接
api.getShareUrl = (params) => {
  return request({
    url: '/yswemini/share/getShareUrl',
    params: params
  })
}


//  唤起微信付款码
api.getPayCodeInfo = () => {
  return request({
    url: '/yswemini/homePageForWeMini/index'
  })
}


//  获取首页积分商品列表
// api.getHomePointsGoods = (params, cancelObj) => {
//   return request({
//     url: '/weMini/homePageForWeMini/getProductRecomList',
//     params: params,
//     cancelObj: cancelObj
//   })
// }
api.getHomePointsGoods = (params, cancelObj) => {
  return request({
    url: '/ysintegrals/product/prdList',
    params: params,
    cancelObj: cancelObj
  })
}

//  获取首页未领取优惠券列表
api.getHomeCouponList = (cancelObj) => {
  return request({
    url: '/yswemini/homePageForWeMini/getSpVoucherList',
    cancelObj: cancelObj
  })
}

//  领取优惠券
api.receiveCoupon = (params) => {
  return request({
    url: '/ysapi/promotion/createVoucher',
    params: params,
    type: 'post'
  })
}

// 签到
api.pointsMallSign = () => {
  return request({
    url: '/ysintegrals/signForIntegrals/sign',
    type: 'get'
  })
}
// 附近门店 ok
api.nearFlagStore = (params) => {
  return request({
    url: '/yswemini/homePageForWeMini/getChainList',
    params: params, // type 1 综合 2 距离 pageNo pageSize longitude latitude name
  })
}

// 获取品牌馆薇姿的跳转地址
api.getBrandsInfo = (params) => {
  return request({
    url: '/yswemini/homePageForWeMini/getSmallProgramUrl',
    params: params,
  })
}

// 获取首页抽奖的轮播
api.getProgramWindow = (params) => {
  return request({
    url: '/yswemini/homePageForWeMini/smallProgramWindow',
    params: params,
  })
}

// 购物车数量
api.getShopCarNum = (params) => {
  return request({
    url: '/ysapi/homePage/getSumOfCart',
    params: params,
  })
}

export default api
